﻿using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System.IO;

namespace Delta.Engine.Tests
{
    [TestClass]
    public class ContentWrapperTest
    {
        [TestMethod]
        public void ContentStreamTest()
        {
            MemoryStream ms = new MemoryStream();
            StreamWriter sw = new StreamWriter(ms);
            sw.WriteLine("Stream Line 1");
            sw.WriteLine("Stream Line 2");
            sw.Flush();

            ms.Seek(0, SeekOrigin.Begin);

            ContentWrapper map1 = new ContentWrapper(ms);

            ms = new MemoryStream();
            sw = new StreamWriter(ms);
            sw.WriteLine("Stream Line 1");
            sw.WriteLine("Stream Line 3");
            sw.WriteLine("Stream Line 4");
            sw.Flush();

            ms.Seek(0, SeekOrigin.Begin);

            ContentWrapper map2 = new ContentWrapper(ms);
 
 
            Assert.IsTrue(map1.ContentLines.Count == 2);

        }

        [TestMethod]
        public void ProcessStreamsTest()
        {
            Processor processor = new Processor();
            MemoryStream ms = new MemoryStream();
            StreamWriter sw = new StreamWriter(ms);
            sw.WriteLine("Stream Line 1");
            sw.WriteLine("Stream Line 2");
            sw.WriteLine("Stream Line 2");
            sw.WriteLine("Stream Line 3");
            sw.WriteLine("Stream Line 3");
            sw.WriteLine("Stream Line 3");
            sw.Flush();

            ms.Seek(0, SeekOrigin.Begin);

            ContentWrapper map1 = new ContentWrapper(ms);

            ms = new MemoryStream();
            sw = new StreamWriter(ms);
            sw.WriteLine("Stream Line 1");
            sw.WriteLine("Stream Line 2");
            sw.WriteLine("Stream Line 2");
            sw.WriteLine("Stream Line 4");
            sw.WriteLine("Stream Line 3");
            sw.WriteLine("Stream Line 3");
            sw.WriteLine("Stream Line 3");
            sw.Flush();

            ms.Seek(0, SeekOrigin.Begin);

            ContentWrapper map2 = new ContentWrapper(ms);

            processor.Process(map1, map2);

            List<DeltaResult> result = processor.Result();

            Assert.IsTrue(result.Count >0);

 
        }
    }
}
